<aside class="sidebar">
    {% include 'Themes/Dabbs/templates/widget-search.twig' %}
    {% set bookTocData = bookToc(data.id,data.contentModel) %}
    {% if bookTocData %}
        <div class="widget widget-nopadding widget-tops affix-top">
            <ul class="widget-nav">
                <li class="active">推荐教程</li>
                <li>文章目录</li>
            </ul>
            <ul class="widget-navcontent">
                <li class="item item-01 active">
                    <ul class="book-list">
                        {% for item in entityList('node',['andWhere':[['conditions':'contentModel = :contentModel:','bind':['contentModel':'book']]],'limit':15]) %}
                            <li><a href="{{ url(['for':'node','id':item.id]) }}">{{ item.title }}</a></li>
                        {% endfor %}
                    </ul>
                </li>
                <li class="item">
                    {% for toc in data.body.toc %}
                        {% if loop.first %}
                            <ul class="book-node-toc toc">
                        {% endif %}
                        <li class="margin-left-{{ getVar(toc,'level') }}">
                            <a href="{{ url(['for':'node','id':data.id]) }}#toc{{ getVar(toc,'tocIndex') }}">{{ getVar(toc,'title') }}</a>
                        </li>
                        {% if loop.last %}
                            </ul>
                        {% endif %}
                    {% else %}
                        没有目录结构
                    {% endfor %}
                </li>
            </ul>
        </div>
    {% else %}
        <div class="widget widget-nopadding widget_ui_text widget_ui_text_list">
            <a class="widget_title">Hi 欢迎来到IT大叔</a>
            <p class="widget_body">大叔关注IT技术文档和发展革新，加入我们，这里有一群共同爱好的人！</p>
            <div class="descrip_button">
                <a target="blank" class="btn btn-info"
                   href="http://shang.qq.com/wpa/qunwpa?idkey=f4a6ffb4b6e624cdc509673609a2f054256425853cb3da0de18804587f310d2d">加入交流QQ群</a>
                {% if user.isLogin() %}
                    <a class="btn btn-default" href="{{ url(['for':'userCenterIndex']) }}">用户中心</a>
                {% else %}
                    <a class="btn btn-default" ajax-model="{{ url(['for':'login']) }}?rd={{ url }}" href="{{ url(['for':'login']) }}?rd={{ url }}">登录/注册</a>
                {% endif %}
            </div>

            {% cache "asidenews" 7200 %}
            <ul class="widget_body">
                {% for item in entityList('node',['limit':5]) %}
                    <li><i><em></em></i><a target="_blank"
                                           href="{{ url(['for':'node','id':item.id]) }}">{{ item.title }}</a>
                        <p>{{ timeTran(item.changed) }}</p>
                    </li>
                {% endfor %}
            </ul>
            {% endcache %}
        </div>
    {% endif %}
    {% cache "commentandtags" 7200 %}
    {% include 'Themes/Dabbs/templates/widget-comment.twig' %}
    {% include 'Themes/Dabbs/templates/widget-tags.twig' %}
    {% endcache %}
</aside>
